<template>
	<view>
		<!-- <u-navbar :is-back="true" :is-fixed="true" title="黑名单"></u-navbar> -->
		<scroll-view scroll-y scroll-with-animation style="height: calc(100vh - 50px)" :show-scrollbar="false"
			@scrolltolower="loadMore" @scrolltoupper="refresh">
			<view class="mt-3 pl-2 pr-2">
				<view v-for="(item, itemIndex) in tabContents" :key="itemIndex">
					<view class="u-line pb-2 mt-1" @click="open(item.id)">
						<view class="dfex">
							<view class="wrapa">{{ item.enterpriseName || '-' }}</view>
							<view class="mt-2 text-999999 font-12">{{ item.updateTime.slice(0, 10) || '-' }}</view>
						</view>
						<view class="wrapa mt-2 text-999999 font-14">{{item.enterprisesReason || '-'}}</view>
					</view>
				</view>
			</view>
			<view v-if="!hasMore && tabContents.length > 0" class="text-center mt-3 mb-3">
				<view class="text-muted">没有更多数据了</view>
			</view>
			<view v-else-if="!hasMore && tabContents.length === 0" class="text-center mt-3 mb-3">
				<view class="iconfont icon-zanwushuju font-48 pb-1"></view>
				<view class="text-999999 font-15">暂时木有内容呀~~</view>
			</view>
			<view v-else class="text-center mt-3 mb-3">
				<view class="btn btn-primary">加载更多</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import $H from '@/common/free-lib/request.js'
	export default {
		data() {
			return {
				tabContents: [],
				form: {
					pageNo: 1,
					pageSize: 10,
					total: 0 // 总页数
				},
				hasMore: true, // 是否还有更多数据
			}
		},
		created() {
			this.getList()
		},
		methods: {
			open(id) {
				uni.navigateTo({
					url: `/pages/tabbar/index/blacklistDi?id=${id}`
				})
			},
			getList() {
				$H.get(
					`/agriculture/blacklist/down/list`, {
						...this.form
					}, {
						token: true
					}
				).then((res) => {
					this.tabContents = res.result.records || [];
					this.form.total = res.result.total;
					this.hasMore = this.tabContents.length < this.form.total;
				})
			},
			// 加载更多
			loadMore() {

				if (this.form.pageNo * this.form.pageSize >= this.form.total) {
					this.hasMore = false;
					return;
				}
				this.form.pageNo++;
				// 请求数据
				this.getList();
			},
			// 下拉刷新
			refresh() {
				// 重置页码为 1
				this.form.pageNo = 1;
				// 清空数据列表
				this.tabContents = [];
				// 设置标记为有更多数据
				this.hasMore = true;
				// 重新请求数据
				this.getList();
				// 结束下拉刷新动画
				uni.$emit('stopPullDownRefresh');
			},
		},
	}
</script>

<style></style>